package startup;


import host.impl.Host;

import org.apache.tools.ant.taskdefs.optional.ssh.SSHExec;

public class StartupManager extends Thread{

	private Host host;
	public StartupManager(Host host){
		this.host = host;
	}
	
	public void startService() {
		this.start();
	}

	public void startRTDG() {
		SSHExec sshexec = new SSHExec();
		sshexec.setCommand("java -jar "+host.getRtdgPath()+" "+host.getContextFile());
		sshexec.setPort(host.getSshpPortNumber());
		sshexec.setHost(host.getIpAddress());
		sshexec.setUsername(host.getLogin());
		sshexec.setPassword(host.getPwd());
		sshexec.setTrust(true);
		sshexec.execute();
	}
	
	/*public void startWindows() {
		SSHExec sshexec = new SSHExec();
		sshexec.setCommand("cmd /c java -jar "+host.getRtdgPath()+" "+host.getContextFile());
		sshexec.setPort(host.getSshpPortNumber());
		sshexec.setHost(host.getIpAddress());
		sshexec.setUsername(host.getLogin());
		sshexec.setPassword(host.getPwd());
		sshexec.setTrust(true);
		sshexec.execute();
	}*/
	
	@Override
	public void run() {
		super.run();
		try{
			startRTDG();
		}catch(Exception e){
			System.out.println("Exception");
		}
	}
}
